package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_org_institution_set")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.OrgInstitutionSetMapper")
public class OrgInstitutionSetDO extends BaseEntity {
    /**
     * 机构主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long orgId;

    /**
     * 出函机构主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long institutionId;

    /**
     * 是否代开发票
     */
    @TableField(value = "invoice_flag")
    private Integer invoiceFlag;

    /**
     * 自动提交开关
     */
    @TableField(value = "auto_submit_flag")
    private Integer autoSubmitFlag;

    /**
     * 截止日期开关
     */
    @TableField(value = "use_apply_day_flag")
    private Integer useApplyDayFlag;

    /**
     * 截止日期前申请天数
     */
    @TableField(value = "apply_days")
    private Integer applyDays;

    /**
     * 截止日期前支付天数
     */
    @TableField(value = "pay_days")
    private Integer payDays;

    /**
     * 截止日期前支付时间
     */
    @TableField(value = "end_pay_time")
    private String endPayTime;

    public OrgInstitutionSetVo buildVo() {
        return new OrgInstitutionSetVo(orgId, institutionId, invoiceFlag, autoSubmitFlag, useApplyDayFlag, applyDays, payDays, endPayTime);
    }

    public static OrgInstitutionSetDO of(OrgInstitutionSetVo vo) {
        return new OrgInstitutionSetDO(vo.getOrgId(), vo.getInstitutionId(), vo.getInvoiceFlag(), vo.getAutoSubmitFlag(), vo.getUseApplyDayFlag(), vo.getApplyDays(), vo.getPayDays(), vo.getEndPayTime());
    }
}
